package work;

import java.io.*;
import java.net.Socket;

/**
 * @auther Macrydy
 * @date 2020/7/16 18:15
 */
public class TcpClient {
    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 10111);

        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("F:\\1.jpg"));

        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);

        int len;
        while ((len = bis.read()) != -1) {
            os.write(len);
        }
        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        bis.close();
        socket.close();

    }
}
